import request from '@/utils/request'
import {encodeParams} from '@/utils'

//树形列表
export function getPageList(data) {
  return request({
    url: '/api/productCategory/list',
    method: 'POST',
    data
  })
}
//一级属性列表
export function getLevel1List(data) {
  return request({
    url: '/api/productCategory/list',
    method: 'POST',
    data
  })
}

//创建
export function create(data) {
  return request({
    url: '/api/productCategory/create',
    method: 'POST',
    data
  })
}

export function findSalesParamByCategoryId(id){
  return request({
    url: `/api/productCategory/findSalesParamByCategoryId/${id}`,
    method: 'GET',
  })
}

export function findByParentId(parentId){
  return request({
    url: `/api/productCategory/findByParentId/${parentId}`,
    method: 'GET',
  })
}

export function getById(id){
  return request({
    url: `/api/productCategory/findById/${id}`,
    method: 'GET',
  })
}

//据启用禁用
export function changeEnable(id,enable) {
  return request({
    url: `/api/productCategory/enable/${id}/${enable}`,
    method: 'GET',
  })
}

//更新
export function update(data) {
  return request({
    url: '/api/productCategory/update',
    method: 'POST',
    data
  })
}

export default {
  getPageList,getLevel1List,create,getById,findByParentId, findSalesParamByCategoryId, update, changeEnable,
}
